!DOCTYPE html>i

+	<head>
+		<meta charset="utf-8">
+		<title></title>
+	</head>
+	<body>
+		输入：<input type="text" id="txt1" /> 转换结果:<input type="text" id="txt1Value" />  
+		<input type="button" id="btnTrun" value="转换为数字" onclick="turnNumber()" />
+		<input type="button" id="btnClear" value="清除" onclick="clearInput()" />		
+		<script>
+			// begin====================>
+			// 演示字符串进行parseInt的结果  
+			function clearInput(){
+				document.getElementById('txt1').value = "";
+				document.getElementById('txt1Value').value = "";
+			}
ocument.getElementById('txt1').value = "";
+                               document.getElemen+			function turnNumber(){
+				var val1 = document.getElementById('txt1').value;
+				if(val1.trim() == ""){
+					alert("请输入有效的值");
+					return;
+				}
+				document.getElementById('txt1Value').value = parseInt(val1);
+// 				if(confirm("转换结束，是否要清除转换结果?")){
+// 					document.getElementById('txt1Value').value = "";
+// 				}
+			}
+			// <<<<<<<<<<<<<<<<<<<<<<<<finish
+			
+			// 开始演示非字符串类型进行强制转换
+			// 1
+			console.log(parseInt([1, 2, 3]));
+			// 3
+			console.log(parseInt([3, 2, 1]));
+			// NaN
+			console.log(parseInt(['a', 2, 1]));
+			// -3
+			console.log(parseInt([-3, 2, 1]));
+			// -3
+			console.log(parseInt([-3, 'a', 'b']));
+			// NaN
+			console.log(parseInt(" "));
+			// NaN
+			console.log(parseInt(true));
+			// NaN
+			console.log(parseInt(false));
+			// NaN
+			console.log(parseInt(null));
+			// NaN
+			console.log(parseInt(undefined));
+			var obj = {"name": "张恒", "age": 18};
+			obj['weight'] = 55;
+			console.log(obj);
+			// NaN
+			console.log(parseInt(obj));
+			// 结束强制转换为int的演示
+		</script>
+	</body>
+</html>
